package com.mmo.cq.game.script.http.gm;

import com.alibaba.fastjson.JSONObject;
import com.mmo.cq.game.server.AppMain;
import org.wxd.net.controller.ann.TextController;
import org.wxd.net.controller.ann.TextMapping;
import org.wxd.net.controller.cmd.RunCode;
import org.wxd.net.web.hs.HttpSession;
import org.wxd.net.web.hs.controller.cmd.HttpFtp;
import org.wxd.str.StringUtil;
import org.wxd.system.JvmUtil;

/**
 * @author: Troy.Chen(無心道, 15388152619)
 * @version: 2023-02-02 16:38
 **/
@TextController(url = "gm")
public class GmComment implements HttpFtp, RunCode {

    /*


     */
    @TextMapping
    public String hotScript() throws Exception {
        AppMain.initScript();
        return "热更代码：" + String.valueOf(this.hashCode());
    }

    @TextMapping
    @Override public void ftp(HttpSession httpSession, JSONObject putData) throws Exception {
        String path = putData.getString("path");
        final String userHome = JvmUtil.userHome();
        if (StringUtil.nullOrEmpty(path) || !path.startsWith(userHome)) {
            putData.put("path", userHome + "/" + "");
        }
        HttpFtp.super.ftp(httpSession, putData);
    }

}
